package com.ruoyi.business.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.business.domain.BizBind;
import com.ruoyi.business.domain.BizScore;
import com.ruoyi.business.domain.BizUser;
import com.ruoyi.common.db.BaseService;
import com.ruoyi.common.db.CacheService;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <pre>
 *
 * </pre>
 *
 * @author zhangli
 * @since 2023/10/22
 */
@Component
public class BizUserDataService extends BaseService<Integer, BizUser> {


    public List<BizUser> getByUserNumber(String userNumber){
        QueryWrapper<BizUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_number",userNumber);

        return selectList(queryWrapper);
    }

    public List<String> getClassNames(String userNumber){
        return  getByUserNumber(userNumber)
                .stream()
                .map(BizUser::getClassName)
                .collect(Collectors.toList());
    }

    public BizUser getUser(String userNumber,String classNames){
        QueryWrapper<BizUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_number",userNumber);
        queryWrapper.eq("class_name",classNames);

        return findOne(queryWrapper);
    }

}
